﻿
<div id="conte-middle">
	<section class="posts">
<?php
	if(isset($episode)){
?>
		<article>
			<header>
				<h1><?php echo $title; ?></h1>
				<p><?php echo lang('v_posted_by'); ?> <span><?php echo $episode['posted_by']; ?></span> <?php echo lang('v_the'); ?> 
					<time datetime="<?php echo $episode['date']; ?>"><?php echo $episode['date']; ?></time>. <?php echo lang('v_updated'); ?> 
					<time datetime="<?php echo $episode['last_update']; ?>"><?php echo $episode['last_update']; ?></time></p>
			</header>
			<div class="post-conte">
				<div class="post-poster float-l">
					<img src="<?php echo $episode['url_poster_big']; ?>" width="277" height="312" />
					<div class="ratingme">
					<?php
						echo '<span class="ms_votes">'.($episode['ranking']==''? 0: $episode['ranking']).'/10 <span>('.$episode['votes'].' '.lang('v_votes').')</span></span>';
					
						$only_read = $selected_star = '';
						if(!isset($usr_info))
							$only_read = ' disabled';
							
						for ($i=1; $i <= 10; $i++) {
							$selected_star = '';
							if($episode['ranking'] == $i)
								$selected_star = ' checked'; 
							echo '<input name="adv1" type="radio" class="starcall {split:2}" id="starcall-'.$episode['id_episode'].'-episode" value="'.$i.'"'.$only_read.$selected_star.'>';
						}
					?></div>
				</div>
				
				<div class="post-info float-r">
					<nav>
						<ul>
						<?php
							$url_cat = '';
							foreach ($episode['categories'] as $keyc => $categorie) {
						 		echo '<li><a href="'.Sys::$url_base.$lang_url.'series~'.$categorie['id'].'/'.'"'.($keyc==0?' class="first"': '').'>'.$categorie['name'].'</a></li>';
							}
							
							$url_season = base_url($lang_url.'series~'.$episode['id_season'].'~'.$episode['clean_title_serie'].'~temporada~'.$episode['no_season']);
						?>
						</ul>
						<div class="clear"></div>
					</nav>
					
					<div class="info">
						<table class="tbl-info">
							<tr>
								<td class="hed" colspan="2"><a href="<?php echo $url_season; ?>"><?php echo lang('v_season').' '.$episode['no_season']; ?></a></td>
							</tr>
							<tr>
								<td class="hed"><?php echo lang('v_release_date'); ?></td>
								<td><?php echo $episode['date_release']; ?></td>
							</tr>
							<tr>
								<td class="hed"><?php echo lang('v_actors'); ?></td>
								<td><?php //Nombres de los actores
								if(is_array($episode['cast'])){
									$ser = '';
									foreach($episode['cast'] as $keys => $source){
										$ser .= ', <a href="'.Sys::$url_base.$lang_url.'actors~'.$source['id'].'/'.'" class="reparto" title="'.$source['name'].'">'.$source['name'].'</a>';
									}
									echo substr($ser, 1);
								}
								?></td>
							</tr>
						</table>
						
						<div class="share">
							<!-- publicidad download -->
							<a href="http://www.down1oads.com/nlp/e/smb/vlc?p1=pelimaniaco&p3=1&utm_source=smb&utm_medium=affiliate&utm_campaign=pelimaniaco&utm_content=vlc" 
								class="btn_descarga" target="_blank" rel="nofollow" style="float: left;margin-top: 90px;"><img src="<?php echo base_url('application/images/download-now.png'); ?>"></a>
							<!-- publicidad download -->

							<div class="share-twit">
								<a href="https://twitter.com/share" class="twitter-share-button" data-count="vertical" data-lang="<?php echo $lang_m; ?>">Tweet</a>
								<script type="text/javascript" src="//platform.twitter.com/widgets.js"></script>
							</div>
							
							<div class="share-plus">
								<!-- Place this tag where you want the +1 button to render -->
								<g:plusone size="tall" href="<?php echo $url_article; ?>"></g:plusone>
								
								<!-- Place this render call where appropriate -->
								<script type="text/javascript">
								  window.___gcfg = {lang: '<?php echo $lang_m; ?>'};
								
								  (function() {
								    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
								    po.src = 'https://apis.google.com/js/plusone.js';
								    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
								  })();
								</script>
							</div>
							<div class="share-face">
								<?php $face_lang = $lang_m.($lang_m=='es'? '_LA': '_US'); ?>
								<div id="fb-root"></div>
								<script>(function(d, s, id) {
								  var js, fjs = d.getElementsByTagName(s)[0];
								  if (d.getElementById(id)) {return;}
								  js = d.createElement(s); js.id = id;
								  js.src = "//connect.facebook.net/<?php echo $face_lang; ?>/all.js#xfbml=1&appId=298068703552361";
									  fjs.parentNode.insertBefore(js, fjs);
									}(document, 'script', 'facebook-jssdk'));</script>
								<div class="fb-like" data-href="<?php echo $url_article; ?>" data-send="false" data-layout="box_count" data-width="20" data-show-faces="false"></div>
							</div>
						</div>
					</div>
				</div>
				<div class="clear"></div>
				<strong class="mini-subtitle"><?php echo lang('v_synopsis') ?></strong>
				<p class="sinop"><?php //Sinopsis
						echo ($lang != 'spa'? $episode['synopsis_'.$lang]: $episode['synopsis_spa']); ?></p>
				<div class="clear"></div>
			</div>
			
			<div class="post-extra">
				<nav>
					<ul>
						<li id="view_download"<?php echo $options['download'][0].lang('v_download_episode').$options['download'][1]; ?></li>
						<li id="view_online"<?php echo $options['online'][0].lang('v_episode_online').$options['online'][1]; ?></li>
						<li id="view_trailer"<?php echo $options['trailer'][0].lang('v_trailer').$options['trailer'][1]; ?></li>
					</ul>
				<?php
				if(isset($usr_info)){
				?>
					<div id="add_marcker_epis" data-url="<?php echo $uri_string; ?>" data-title="<?php echo $title; ?>" 
						data-obj="<?php echo $episode['id_episode']; ?>" title="<?php echo lang('v_add_marker'); ?>"></div>
				<?php 
				} ?>
					<div class="clear"></div>
				</nav>
				<div class="extra-conte corner-all">
				<?php 
					switch ($opc_selected) {
						case 'online':
						case 'download':
						case 'trailer':
							$viewopc = array('display:none;', 'display:none;', 'display:none;');
							if(strpos($options['online'][0], 'class') > 0)
								$viewopc[0] = 'display:table;';
							elseif(strpos($options['download'][0], 'class') > 0)
								$viewopc[1] = 'display:table;';
							elseif(strpos($options['trailer'][0], 'class') > 0)
								$viewopc[2] = 'display:table;';
							
							echo '<div id="reproductor">
								<h2>'.lang('v_select_sourse').'</h2>
								<table id="sonline" cellpadding="0" cellspacing="0" style="'.$viewopc[0].'">
									<tr class="hed">
										<td>Enlace</td>
										<td>Servidor</td>
										<td>Audio</td>
										<td>Subtitulos</td>
										<td>Info.</td>
										<td>Uploader</td>
										<td>Calif.</td>
									</tr>';
							//Nombres de los servidores
							if(isset($episode['sources'])){
								if(is_array($episode['sources'])){
									$download = $url_s = $info = '';

									if ($plugin_online_browser !== '') {
										echo '<tr class="cont">
												<td colspan="7">
													<a href="'.$plugin_online_browser.'" rel="nofollow" target="_blank">
													<img src="'.base_url('application/images/'.$plugin_online_icon.'.png').'" alt="'.lang('v_download').' Plugin" title="'.lang('v_download').' Plugin" width="64" height="64" style="vertical-align: middle;color: blue;" />
													'.$plugin_online_title.'</a>
												</td>
											</tr>';
									}

									foreach($episode['sources'] as $keys => $source){
										if($source['url_subtitle']!='')
											$source['subtitle'] = '<a href="'.$source['url_subtitle'].'" class="subs" rel="nofollow" target="_blank">'.$source['subtitle'].'</a>';
										$info = '<span>Calidad</span>: '.$source['quality'].'<br>'.
												($source['format_film']!=''? '<span>Formato</span>: '.$source['format_film'].' <br>': '').
												($source['duration']!=''? '<span>Duración</span>: '.$source['duration'].' <br>': '').
												($source['size']!=''? '<span>Tamaño</span>: '.$source['size']: '');
										
										$url_s = $source['short']!=''? $source['short']: $source['origen'];	
										
										if($source['online1'] == 0 || $source['online1'] == 2){  //Fuentes descarga directa
											$download .= '
										<tr class="cont">
											<td><a href="'.$url_s.'" class="play download" rel="nofollow" target="_blank">Descargar</a></td>
											<td><img src="'.$source['url_img'].'" width="150" height="50" alt="'.lang('v_download').' '.$source['name'].'" /></td>
											<td>'.$source['language'].'</td>
											<td>'.$source['subtitle'].'</td>
											<td><a class="tipinfo" original-title="'.($info!=''? $info: 'No  info').'">
												<img src="'.base_url('application/images/excl_info.png').'" width="16" height="16"></a></td>
											<td>'.$source['user'].'</td>
											<td><span class="good" data-type="e" data-opc="g" data-obj="'.$source['id_source'].'">'.$source['votes_pos'].'</span> <br>
												<span class="bad" data-type="e" data-opc="b" data-obj="'.$source['id_source'].'">'.$source['votes_neg'].'</span></td>
										</tr>';
										}
										
										if($source['online1'] == 1 || $source['online1'] == 2 || $source['online'] == 1){ //Fuentes online
											if($source['online1'] == 2)
												$url_s = $source['origen'].(strpos($source['origen'], '?')===FALSE? '?': '&').'maniaco='.MyConf::plugin_version.'&video='.$episode['id_episode'].'&t=e';
											echo '
										<tr class="cont">
											<td><a href="'.$url_s.'" class="play" '.($source['online_pelim']==1? 'data-rel="superbox[iframe][700x450]"': '').' rel="nofollow" target="_blank">Reproducir</a></td>
											<td><img src="'.$source['url_img'].'" width="150" height="50" alt="'.lang('v_download').' '.$source['name'].'" /></td>
											<td>'.$source['language'].'</td>
											<td>'.$source['subtitle'].'</td>
											<td><a class="tipinfo" original-title="'.($info!=''? $info: 'No  info').'">
												<img src="'.base_url('application/images/excl_info.png').'" width="16" height="16"></a></td>
											<td>'.$source['user'].'</td>
											<td><span class="good" data-type="e" data-opc="g" data-obj="'.$source['id_source'].'">'.$source['votes_pos'].'</span> <br>
												<span class="bad" data-type="e" data-opc="b" data-obj="'.$source['id_source'].'">'.$source['votes_neg'].'</span></td>
										</tr>';
										}
									}
								}else{
									echo '<tr>
										<td colspan="7"><strong style="color:#E74B39; font-size: 1.1em;">'.lang('v_not_sourse').'</strong></td>
									</tr>';
								}
							}else{
								echo '<tr>
										<td colspan="7"><strong style="color:#E74B39; font-size: 1.1em;">'.lang('v_not_sourse').'</strong></td>
									</tr>';
							}
							echo '</table>';
								
							//Tabla de fuentes descarga directa
							echo '<table id="sdownload" cellpadding="0" cellspacing="0" style="'.$viewopc[1].'">
									<tr class="hed">
										<td>Enlace</td>
										<td>Servidor</td>
										<td>Audio</td>
										<td>Subtitulos</td>
										<td>Info.</td>
										<td>Uploader</td>
										<td>Calif.</td>
									</tr>';
							if(isset($download))
								echo $download;
							else
								echo '<tr>
										<td colspan="7"><strong style="color:#E74B39; font-size: 1.1em;">'.lang('v_not_sourse').'</strong></td>
									</tr>';
							echo '</table>';
							
							//Trailer de la peli
							echo '<div id="strailer" style="'.$viewopc[2].'">';
							if(isset($episode['trailer'])){
								if($episode['trailer'] != '')
									echo '<iframe width="560" height="315" class="iftrailer" src="http://www.youtube.com/embed/'.$episode['trailer'].'" frameborder="0" allowfullscreen></iframe>';
							}
							echo '</div>
							</div>';
						break;
						case 'capturs':
							if(isset($episode['screenshots'])){
								$links = '';
								$conta = 1;
								foreach ($episode['screenshots'] as $key => $value) {
									if($value['primary'] == 1)
										echo '<a href="'.$value['url_screen'].'" target="_blank"><img src="'.$value['url_screen'].'" width="615" /></a>';
									else{
										$links .= '<a href="'.$value['url_screen'].'" class="screen" target="_blank">'.lang('v_screenshot').' '.$conta.'</a>';
										$conta++;
									}
								}
								echo $links;
							}
						break;
					}
				?>
				</div>
				<div class="clear"></div>
				
				<nav class="episodes">
					<strong class="mini-subtitle"><?php echo lang('v_episode') ?>s</strong>
					<ul>
			<?php
				if(is_array($season['episodes'])){
					$ser = '';
					foreach($season['episodes'] as $keys => $source){
						$ser = '';
						if($source['release_date'] != '')
							$ser = ' => '.lang('v_release_date').' '.$source['release_date'];
						
						if($source['id'] == $episode['id_episode'])
							echo '<li><span style="font-weight:bold;">'.lang('v_episode').' '.$source['no_episode'].' - '.$source['title'].'</span>'.$ser.'</li>';
						elseif($source['status'] == '1')
							echo '<li><a href="'.base_url($lang_url.'series~'.$source['id'].'~'.$season['clean_title'].'~'.$source['clean_title']).
								'" class="reparto">'.lang('v_episode').' '.$source['no_episode'].' - '.$source['title'].'</a>'.$ser.'</li>';
						else
							echo '<li><span>'.lang('v_episode').' '.$source['no_episode'].' - '.$source['title'].'</span>'.$ser.'</li>';
						
					}
				} 
			?>
					</ul>
				</nav>
				
				<div class="clear"></div>
				<div class="comments_face">
					<strong class="mini-subtitle"><?php echo lang('v_comments') ?></strong>
					<div id="fb-root"></div>
					<script>(function(d, s, id) {
					  var js, fjs = d.getElementsByTagName(s)[0];
					  if (d.getElementById(id)) {return;}
					  js = d.createElement(s); js.id = id;
					  js.src = "//connect.facebook.net/<?php echo $face_lang; ?>/all.js#xfbml=1&appId=298068703552361";
					  fjs.parentNode.insertBefore(js, fjs);
					}(document, 'script', 'facebook-jssdk'));</script>
					<div class="fb-comments" data-href="<?php echo $url_article; ?>" data-num-posts="30" data-width="640"></div>
				</div>
			</div>
		</article>
<?php
	}
?>
		
	</section>

